import type { IDict } from './dict'
import type { BodyType } from './basic'

export const defualtWithIUICase: IUICase = {
  id: -1,
  moduleId: -1,
  browser: 'CHROME',
  name: '默认名称',
  cyclesNum: 1,
  level: 'p0',
  beforeCaseIds:[],
  status: '未执行',
  headArguments: 'HEAD',
  description: '无描述',
  createAccountId: 0,
  updateAccountId: 0,
  gmtCreate: new Date(),
  gmtModified: new Date(),
  stepList: [],
}


export interface IUICase {
  id: number
  moduleId: number
  browser: string
  name: string
  cyclesNum: number
  level: string
  beforeCaseIds: string | string[]
  status: string
  headArguments: string
  description: string
  createAccountId: number
  updateAccountId: number
  gmtCreate: Date
  gmtModified: Date
  stepList: IUICaseStep[]
}

export const defaultWithIUICaseStep: IUICaseStep = {
  id: -1,
  caseId: -1,
  databaseId: -1,
  num: -1,
  assertion: '',
  name: '默认名称',
  type: '',
  engineType: 'UI',
  operationType: '',
  locationType: '',
  locationExpress: '',
  elementWait: 0,
  targetLocationType: '',
  targetLocationExpress: '',
  targetElementWait: 0,
  value: '',
  expectKey: '',
  expectValue: '',
  description: '',
  saveKey: '',
  isContinue: false,
  isScreenshot: false,
  sqlText: '',
  isRetry: false,
  retryType: "同步",
  retryCount: 1,
  retryFirstInterval: 3,
  createAccountId: -1,
  updateAccountId: -1,
  gmtCreate: new Date(),
  gmtModified: new Date(),
  bodyType: 'JSON',
}

export interface IUICaseStep {
  id: number
  caseId: number
  databaseId: number
  num: number
  assertion: string
  name: string
  type: string
  engineType: string
  operationType: string
  locationType: string
  locationExpress: string
  elementWait: number
  targetLocationType: string
  targetLocationExpress: string
  targetElementWait: number
  value: string
  expectKey: string
  expectValue: string
  description: string
  saveKey: string
  isContinue: boolean
  isScreenshot: boolean
  sqlText: string
  isRetry: boolean
  retryType: string
  retryCount: number
  retryFirstInterval: number
  createAccountId: number
  updateAccountId: number
  gmtCreate: Date
  gmtModified: Date
 
  bodyType: BodyType
}











export const defaultWithIUICaseStepAssertion: IUICaseStepAssertion = {
  from: 'response_code',
  type: 'regexp',
  action: 'equal',
  express: '',
  value: '',
}

export interface IUICaseStepAssertion {
  from: 'response_code' | 'response_header' | 'response_body'
  type: 'regexp' | 'jsonpath'
  action:
    | 'contain'
    | 'not_contain'
    | 'equal'
    | 'not_equal'
    | 'great_then'
    | 'less_then'
  express: string
  value: string
}

export const defaultWithIUICaseStepRelation: IUICaseStepRelation = {
  from: 'request_header',
  type: 'regexp',
  express: '',
  name: '',
}

export interface IUICaseStepRelation {
  from:
    | 'request_header'
    | 'request_body'
    | 'request_query'
    | 'response_header'
    | 'response_body'
  type: 'regexp' | 'jsonpath'
  express: string
  name: string
}

export const defaultWithIUIConstantSelectOptions: IUIConstantSelectOptions = {
  ui_location_type: [],
  mix_relate_type: [],
  mix_relate_field_from: [],
  mix_assert_type: [],
  mix_assert_field_from: [],
  mix_assert_action: [],
}

export interface IUIConstantSelectOptions {
  ui_location_type: IDict[]
  mix_relate_type: IDict[]
  mix_relate_field_from: IDict[]
  mix_assert_type: IDict[]
  mix_assert_field_from: IDict[]
  mix_assert_action: IDict[]
}